package interview.design.singleton;

/**
 * Created by yzy on 2021-01-29 18:40
 */
public class DoubleCheckSingleton {

    private volatile static SingletonResource resource;

    /**
     * 双检锁，延迟初始化
     * @return
     */
    public static SingletonResource getResource(){
        if(resource == null){
            synchronized (resource){
                if(resource == null){
                    resource = new SingletonResource();
                }
            }
        }
        return resource;
    }


}
